console.log('script.js');

const originOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function (_, url) {
  if (url.startsWith("https://img-home.csdnimg.cn/data_json/jsconfig/rank_nav_list.json")) {
    console.log(url);
    this.addEventListener("readystatechange", function () {
      console.log("readystatechange");
      if (this.readyState === 4) {
        const res = JSON.parse(this.responseText);
        // 当前 xhr 对象上定义 responseText
        Object.defineProperty(this, "responseText", {
          writable: true,
        });
        res.name = 'goahead';
        let filterSwitch = localStorage.getItem('filterSwitch');
        if (!filterSwitch) {
          filterSwitch = 'true';
        }
        if (filterSwitch === 'true') {
          res.list.splice(2, 15)
        }

        this.responseText = JSON.stringify(res);
        console.log(this.responseText);
      }
    });
  }
  originOpen.apply(this, arguments);
};